home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!smryan
- From: smryan@netcom.com (@#$%!?!)
- Subject: Re: C syntax question
- Message-ID: <smryanDponD1.5KI@netcom.com>
- Organization: The Programmer formerly known as S M Ryan
- X-Newsreader: TIN [version 1.2 PL1]
- References: <4ki00k$a4@mailhub.scitec.com.au>
- Date: Thu, 11 Apr 1996 05:31:48 GMT
- Sender: smryan@netcom19.netcom.com
-
- "Doctor, it hurts when I do this!"
- "Then don't do it."
-
- : This is supposedly correct C, typedef names are ignored when defining
- : structure members. But not when defining variables so:
- : byte byte;
- : is an error when not inside a structure definition. Am I correct so far?
-
- There's a very good chance a c parser will use the same code for struct
- members and variable declarations. Perhaps a few flags thrown in. Unless
- many people do this kind of thing, that will probably not change.
-
- : ubyte signed i;
- : byte unsigned j;
- : signed ubyte k;
- : unsigned byte l;
-
- Presumably the parsers are panicking if after collected some specs, they
- see a typedef-name, before they peek inside the typedef. Once they do, they
- are probably replacing the name with definition immediately and so can
- handle additional specs. Since a typedef-name is not generally compatiable
- with signed or long, parser writer probably took the easy way.
-
- While you are (I assume) correct in both cases, and it would be nice if you
- (and others) did it right, you'll be hard pressed to get anybody (except
- yourself) to do anything about it.
-
- : of typedef names or type keywords in any order. This is causing a major
- : problem in being able to parse "byte byte;" correctly in the structure
- : definition. I.e. is the second occurance of "byte" supposed to be treated as
- : a typedef name or the member name?
-
- With a two token lookahead, the ambiguity dissappears. The member name must
- be followed by "," ":" or ";". Allowing function parameter names to be
- typedef-names would be ambiguous: void f(signed byte), is "signed byte" an
- abstract or actual declarator?
-
- --
- The Queen, amused, in quiet power, | smryan@netcom.com PO Box 1563
- will draw the son to darkenned bower. | Cupertino, California
- Her face is fair, her fragrance rare, | (xxx)xxx-xxxx 95015
- with woven webs for wayward flower. | I don't use no smileys
-